Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CString::operator []
CString                                     Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  char operator []( int nIndex ) const;
 
  Remarks
 
  You can think of a CString object as an array of characters. The
  subscript ([]) operator returns a single character specified by the
  zero-base index in <nIndex>. This operator is a convenient substitute
  for the GetAt member function.
 
  You can use the subscript ([]) operator on the right side of an
  expression (r-value semantics), but you cannot use it on the left side
  of an expression (l-value semantics). That is, you can use this operator
  to get characters in a CString, but you cannot use it to set characters
  in the CString.
 
  Example
 
  CString s( "abc" );
  ASSERT( s[1] == 'b' );
 
 
  See Also
 
  CString::GetAt, CString::SetAt
 
 
                                     -♦-